package com.topscore.uke.mvp.model;

import com.topscore.uke.mvp.contractors.UpdateMemberInfoContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.request.MemberInfoUpdateRequest;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 71468 on 2017/10/24.
 */

public class UpdateMemberInfoModel implements UpdateMemberInfoContractor,UpdateMemberInfoContractor.Model {

    private CallBack mCallBack;

    public UpdateMemberInfoModel(CallBack callBack) {
        this.mCallBack = callBack;
    }

    @Override
    public void update(MemberInfoUpdateRequest request) {
        mService.updateMemberInfo(request)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse>(mCallBack) {
                    @Override
                    public void onSuccess(BaseResponse response) {
                        mCallBack.onUpdateSuccess();
                    }
                });
    }
}
